const app= require('express')()
const router=require('./router')
//乱码中间件
app.use((req,resp,next)=>{
    resp.header('Content-Type','text/html;charset=utf-8');
    next();
})
const bodyPaser=require('body-parser');
app.use(bodyPaser.urlencoded({extended:false}));
app.use(bodyPaser.json());
//跨域中间件
app.use((req,resp,next)=>{
    resp.header("Access-Control-Allow-Credentials", true);
    resp.header("Access-Control-Allow-Origin", "*");
    resp.header("Access-Control-Allow-Headers", "X-Requested-With");
    resp.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    resp.header("X-Powered-By", ' 3.2.1');
    resp.header("Content-Type", "application/json;charset=utf-8");
    next();
})
router(app)

app.listen(9001)
console.log('localhost:9001')